bitkeeper revision 1.989 (40d67c9em66pd7yVqnpYax0LoJ-lzw)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 21 Jun 2004 06:13:50 +0000 (06:13 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 21 Jun 2004 06:13:50 +0000 (06:13 +0000)
Bug fixes.

xen/common/dom0_ops.c
xen/common/schedule.c

index ea298eeac5fda23b572d4d818c4f8962a8313533..515ff4d2b8fb1a37cc7024d95dc1a1795190a5ef 100644 (file)
@@ -103,9 +103,13 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         ret = -ESRCH;
         if ( d != NULL )
         {
-            domain_stop(d);
+            ret = -EINVAL;
+            if ( d != current )
+            {
+                domain_stop(d);
+                ret = 0;
+            }
             put_domain(d);
-            ret = 0;
         }
     }
     break;
@@ -173,9 +177,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
             if ( d != current )
             {
                 domain_kill(d);
-                put_domain(d);
                 ret = 0;
             }
+            put_domain(d);
         }
     }
     break;
@@ -183,34 +187,35 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     case DOM0_PINCPUDOMAIN:
     {
         domid_t dom = op->u.pincpudomain.domain;
+        struct domain *d = find_domain_by_id(dom);
+        int cpu = op->u.pincpudomain.cpu;
+
+        if ( d == NULL )
+        {
+            ret = -ESRCH;            
+            break;
+        }
         
-        if ( dom == current->domain || dom == IDLE_DOMAIN_ID )
+        if ( d == current )
+        {
             ret = -EINVAL;
+            put_domain(d);
+            break;
+        }
+
+        if ( cpu == -1 )
+        {
+            clear_bit(DF_CPUPINNED, &d->flags);
+        }
         else
         {
-            struct domain *d = find_domain_by_id(dom);
-            int cpu = op->u.pincpudomain.cpu;
-            
-            ret = -ESRCH;
-            
-            if ( d != NULL )
-            {
-                if ( cpu == -1 )
-                {
-                    clear_bit(DF_CPUPINNED, &d->flags);
-                }
-                else
-                {
-                    domain_pause(d);
-                    set_bit(DF_CPUPINNED, &d->flags);
-                    cpu = cpu % smp_num_cpus;
-                    d->processor = cpu;
-                    domain_unpause(d);
-                }
-                put_domain(d);
-                ret = 0;
-            }      
+            domain_pause(d);
+            set_bit(DF_CPUPINNED, &d->flags);
+            d->processor = cpu % smp_num_cpus;
+            domain_unpause(d);
         }
+
+        put_domain(d);
     }
     break;
 
@@ -293,7 +298,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         op->u.getdomaininfo.flags =
             (test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
 
-        domain_pause(d);
+        if ( d != current )
+            domain_pause(d);
 
         op->u.getdomaininfo.domain = d->domain;
         strcpy(op->u.getdomaininfo.name, d->name);
@@ -381,7 +387,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
             ret = -EINVAL;
 
     gdi_out:
-        domain_unpause(d);
+        if ( d != current )
+            domain_unpause(d);
         put_domain(d);
     }
     break;
index cfae3bfedcc178a1abf46d5de2e545a15f45d4ec..d9cb33fdb5a6d3d677b976fa8c761c0d7f4187f9 100644 (file)
@@ -178,16 +178,17 @@ void domain_sleep(struct domain *d)
     int           cpu = d->processor;
 
     spin_lock_irqsave(&schedule_lock[cpu], flags);
-
-    if ( test_bit(DF_RUNNING, &d->flags) )
-        cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
-    else if ( __task_on_runqueue(d) )
-        __del_from_runqueue(d);
-
+    if ( likely(!domain_runnable(d)) )
+    {
+        if ( test_bit(DF_RUNNING, &d->flags) )
+            cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ);
+        else if ( __task_on_runqueue(d) )
+            __del_from_runqueue(d);
+    }
     spin_unlock_irqrestore(&schedule_lock[cpu], flags);
 
     /* Synchronous. */
-    while ( test_bit(DF_RUNNING, &d->flags) )
+    while ( test_bit(DF_RUNNING, &d->flags) && !domain_runnable(d) )
     {
         smp_mb();
         cpu_relax();